﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>患者详情</title>
    <link href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/ligerui-icons.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/Gray/css/all.css" rel="stylesheet" />
    <link href="~/Content/css/common.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMddHH")"></script>
    <link href="~/Scripts/laydate/theme/default/laydate.css" rel="stylesheet" />
    <script src="~/Scripts/laydate/laydate.js"></script>
    <style type="text/css">
			.radio_label{display:inline-block;width:auto;height:22px;background:url(/content/images/radiobutton.png) no-repeat;background-position:-13px -16px;text-indent:22px;line-height:22px;}
	.radio_label:hover{background-position:-13px -116px;}
	input[type=radio]{width:0;}
	.checkbox_label{display:inline-block;width:auto;height:22px;background:url(/content/images/checkboxbutton.png) no-repeat;background-position:-13px -16px;text-indent:22px;line-height:22px;}
	.checkbox_label:hover{background-position:-13px -116px;}
	.checked{background-position:-13px -216px;}
	.checked:hover{background-position:-13px -216px;}
	input[type=checkbox]{width:0;}
    </style>
</head>
<body>
    <form> 
    <div style="margin:10px 5px;">
        <table border="0">
            <tr>
                <td style="width:100px;text-align:right;line-height:30px;">
                    登记时间：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtCreateTime" name="txtCreateTime" class="l-text" />
                </td>
                <td style="width:100px;text-align:right;line-height:30px;">
                    患者姓名：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtRealName" name="txtRealName" class="l-text" />
                </td>
            </tr>
            <tr>
                <td style="width:100px;text-align:right;line-height:30px;">
                    身份证：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtIDCard" name="txtIDCard" class="l-text" />
                </td>
                <td style="width:100px;text-align:right;line-height:30px;">
                    年龄：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtAge" name="txtAge" class="l-text" typeof="number" />
                </td>
            </tr>
            <tr>
                <td style="width:100px;text-align:right;line-height:30px;">
                    联系电话：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtPhoneNum" name="txtPhoneNum" class="l-text" />
                </td>
                <td style="width:100px;text-align:right;line-height:30px;">
                    性别：
                </td>
                <td style="width:140px;line-height:30px;">
                    <label for="eventGrade1">
                        <input type="radio" id="eventGrade1" name="eventGrade" value="1" checked="checked" />&nbsp;男
                    </label>
                    <label for="eventGrade2">
                        <input type="radio" id="eventGrade2" name="eventGrade" value="0" />&nbsp;女
                    </label>
                </td>
            </tr>
            <tr>
                <td style="width:100px;text-align:right;line-height:30px;">
                   住址：
                </td>
                <td colspan="3">
                    <input type="text" id="txtAddress" name="txtAddress" class="l-text" style="width:370px;" />
                </td>
            </tr>
            <tr>
                <td style="width:100px;text-align:right;line-height:30px;">
                     门诊ID：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtPicaId" name="txtPicaId" class="l-text" readonly="readonly" />
                </td>
                <td style="width:100px;text-align:right;line-height:30px;">
                    住院ID：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtLivePicId" name="txtLivePicId" class="l-text" />
                </td>
            </tr>
            <tr>
                <td style="width:100px;text-align:right;line-height:30px;">
                    发病时间：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input type="text" id="txtillTime" name="txtillTime" class="l-text" />
                </td>
                <td style="width:100px;text-align:right;line-height:30px;">
                    <span style="color:#ff0000">*</span>卒中诊断：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input id="ddldiagnosisofchestpain" type="text" />
                </td>
            </tr>
            <tr>
                <td style="width:100px;text-align:right;line-height:30px;">
                    发病地址：
                </td>
                <td colspan="3">
                    <input type="text" id="txtillAddress" name="txtillAddress" />
                </td>
            </tr>            
            <tr>
                <td style="width:100px;text-align:right;line-height:30px;">
                    来院方式：
                </td>
                <td style="width:140px;line-height:30px;">                     
                        <input id="ddlfromhospitalType" type="text" />
                </td>
                <td style="width:100px;text-align:right;line-height:30px;">
                    入院途径：
                </td>
                <td style="width:140px;line-height:30px;">
                    <input id="ddlcomeinType" type="text" />
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding-top:20px; text-align:center;">
                    <input type="hidden" id="txtId" name="txtId" value="" />
                    <input id="btnClose" type="button" value="关闭" class="l-button" />
                    <input id="btnSave" type="button" value="保存" class="l-button" />
                </td>
            </tr>
        </table>
    </div>
        </form>
    <script>
    $(function () {
        $("#txtCreateTime").val(CurentDateTime());
        laydate.render({ elem: '#txtCreateTime', type: 'datetime' });
        laydate.render({ elem: '#txtillTime', type: 'datetime' });
        //来院方式
        $("#ddlfromhospitalType").ligerComboBox({
            data: [{ "ID": -1, "Name": "-请选择-" }, { "ID": 0, "Name": "本院急救车" }, { "ID": 1, "Name": "当地120" }, { "ID": 2, "Name": "外院转院" }, { "ID": 3, "Name": "自行来院" }],
            isMultiSelect: false,
            valueField: "ID",
            textField: "Name",
            value: -1,
            valueFieldID: 'txtfromhospitalType',
        });
        //入院途径
        $("#ddlcomeinType").ligerComboBox({
            data: [{ "ID": -1, "Name": "-请选择-" }, { "ID": 0, "Name": "急诊" }, { "ID": 1, "Name": "门诊" }, { "ID": 2, "Name": "其他医疗机构转入" }, { "ID": 3, "Name": "其他" }],
            isMultiSelect: false,
            valueField: "ID",
            textField: "Name",
            value: -1,
            valueFieldID: 'txtcomeinType',
        });
        //卒中诊断
        $("#ddldiagnosisofchestpain").ligerComboBox({
            data: [{ "ID": -1, "Name": "-请选择-" }, { "ID": 0, "Name": "CEA 、 CAS" }, { "ID": 1, "Name": "静脉溶栓、血管内介入" }, { "ID": 2, "Name": "脑出血" }, { "ID": 3, "Name": "颅内动脉瘤" }],
            isMultiSelect: false,
            valueField: "ID",
            textField: "Name",
            value: -1,
            valueFieldID: 'txtdiagnosisofchestpain',
        });
        //发病地址
        $("#txtillAddress").ligerComboBox({
            width: 370,
            isTextBoxMode: true,
            data: [{ "ID": "家中", "Name": "家中" }, { "ID": "户外", "Name": "户外" }, { "ID": "院外", "Name": "院外" }, { "ID": "院内", "Name": "院内" }],
            isMultiSelect: false,
            valueField: "ID",
            textField: "Name",
            value: "",
            valueFieldID: 'txthdnillAddress',
        });
        $(":text[typeof=number]").keyup(function () {
            var c = $(this);
            if (/[^\d]/.test(c.val())) {
                var num = c.val().replace(/[^\d]/g, '');
                $(this).val(num == "" ? "" : parseInt(num));
            }
        })
        $("#txtIDCard").on("blur", function () {
            var val = $(this).val();
            if (val == "") return;
            var idcardReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
            if (!idcardReg.test(val)) {
                $.ligerDialog.error("身份证不合法");
            } else {
                var bornYear = parseInt(val.substring(6, 10));
                var nowYear = new Date().getFullYear();
                $("#txtAge").val((nowYear - bornYear));
            }
        })
        //保存事件
        $("#btnSave").click(function () {
            var arr = $("form").serializeArray();
            var obj = {};
            for (var i = 0; i < arr.length; i++) {
                obj[arr[i].name] = arr[i]['value']
            }
            $.post("/StrokeCenter/PatientList/Save", obj, function (data, textStatus) {
                if (textStatus == "success") {
                    var d = $.parseJSON(data);
                    if (d.Result == 1) {
                        $.ligerDialog.success("保存成功","", function () {
                            parent.window.btnSearch.click();
                            frameElement.dialog.close();
                        });
                    }
                    else if (d.Result == 0) {
                        $.ligerDialog.error(d.Body);
                    }
                    else {
                        $.ligerDialog.error("程序错误");
                    }
                }
            })
        });
        $("#btnClose").click(function () {
            parent.window.btnSearch.click();
            frameElement.dialog.close();
        });
        //单选框
        $("input[type=radio]").parent().addClass("radio_label");
        $("input[type=radio][disabled!=disabled]").click(function (e) {
            $("input[type=radio][name='" + $(this).attr('name') + "']").parent().removeClass("checked");
            $(this).parent().addClass("checked");
        });
        $("input[type=radio][checked=checked]").parent().addClass("checked");
        if (navigator.userAgent.indexOf("Firefox") > 0) { $(":radio,:checkbox").hide(); }
        //复选框	 
        $("input[type=checkbox]").parent().addClass("checkbox_label");
        $("input[type=checkbox][disabled!=disabled]").click(function (e) {
            if ($(this).parent().hasClass("checked"))
                $(this).parent().removeClass("checked");
            else
                $(this).parent().addClass("checked");
        });
        $("input[type=checkbox][checked=checked]").parent().addClass("checked");
        setValue();
    });
    function setValue() {
        if ("@ViewBag.Id" != "" && "@ViewBag.Id" != "0") {
            $.ajax({
                url: '/PatientList/Search?Id=' + "@ViewBag.Id" + '&rnd=' + getRnd(),
                cache: false,
                dataType: 'json',
                success: function (data) {
                    if (data.Total > 0) {
                        var Row = data.Rows[0];
                        $('#txtId').val(Row.ID);
                        $('#txtCreateTime').val(obj2Timemm(Row.RegisterTime));
                        $('#txtRealName').val(Row.PATIENT_NAME);
                        $('#txtIDCard').val(Row.PATIENT_ID_NUM);
                        $('#txtAge').val(Row.PATIENT_AGE);
                        $('#txtPhoneNum').val(Row.PATIENT_PHONE);
                        RadioSetVal("eventGrade", Row.PATIENT_SEX, true);
                        $('#txtAddress').val(Row.PATIENT_ADDR);
                        $('#txtPicaId').val(Row.PATIENT_ID == "0" ? "" : Row.PATIENT_ID);
                        $('#txtLivePicId').val(Row.Hospital_ID);
                        $('#txtillTime').val(obj2Timemm(Row.ems_disease_time));
                        $("#ddlfromhospitalType").ligerGetComboBoxManager().setValue(IsEmpty(Row.PATIENT_ARRIVE_CLASS) ? "-1" : Row.PATIENT_ARRIVE_CLASS);
                        $("#ddlcomeinType").ligerGetComboBoxManager().setValue(IsEmpty(Row.AdmissionPath) ? "-1" : Row.AdmissionPath);
                        $("#ddldiagnosisofchestpain").ligerGetComboBoxManager().setValue(IsEmpty(Row.Stroke_Diagnosis) ? "-1" : Row.Stroke_Diagnosis);
                        if (Row.Stroke_Diagnosis != "-1" && !IsEmpty(Row.Stroke_Diagnosis)) $("#ddldiagnosisofchestpain").ligerGetComboBoxManager().setDisabled();
                        $("#txtillAddress").ligerGetComboBoxManager().setValue(Row.EMS_DISEASE_ADDR);
                    } else {
                        $.ligerDialog.error("获取患者信息失败");
                    }
                }
            });
        }
    }
    </script>
</body>
</html>
